<template>
  <view class="content">
    <view class="title">
      <text>子组件B</text>
    </view>
    <view class="coma_box">
      <text class="label">CompA组件传进来的值：</text>
      <text class="value">{{result}}</text>
    </view>

    <view class="coma_box flex-row" style="margin: 10rpx 0;">
      <text class="label">回传值：</text>
      <input type="text" v-model="callbackValue" class="input" />
      <button @click="sendOutside()" size="mini" class="btn">回传</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      result: '',
      callbackValue: '0592-2788888'
    };
  },
  created() {
    uni.$on('getIntent', (msg) => {
      console.error('---CompB---getIntent----->' + msg);
      this.result = msg;
    });
  },
  methods: {
    sendOutside() {
      console.warn('---CompB---sendOutside----->' + this.callbackValue);
      this.$emit('callBackFun', this.callbackValue);
    }
  }
};
</script>

<style scoped>
.content {
  padding: 20rpx;
  background-color: #eef2ff; 
}

.title {
  text-align: center;
  margin-bottom: 20rpx;
  font-size: 40rpx;
  font-weight: bold;
}

.coma_box {
  margin-bottom: 20rpx;
  text-align: center;
  font-size: 30rpx;
}

.coma_box .label {
  font-weight: bold;
  color: #666;
  margin-right: 10rpx;
}

.coma_box .value {
  font-weight: bold;
  color: blue;
}

.flex-row {
  display: flex;
  align-items: center;
  justify-content: center; 
}

.input {
  width: 200rpx;
  height: 50rpx;
  border: 1px solid #ccc;
  margin: 0 10rpx;
  padding: 0 10rpx;
  color: blue;
  font-size: 28rpx;
}

.btn {
  margin-left: 10rpx;
}
</style>